// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "SmartMenu.h"
#include "Json.h"
#include "SmartCore.h"
#include "SmartMenuHandle.generated.h"


UCLASS(Blueprintable, BlueprintType)
class USmartMenuHandle : public UObject
{
	GENERATED_BODY()
	//USmartMenuHandle();
	USmartMenuHandle(const FObjectInitializer& ObjectInitializer);

private:
	static USmartMenuHandle* SmartMenuHandleInstance;
	static USmartMenu* LevelToolbarMenu;
	static USmartMenu* AssetSmartMenu;
	static USmartMenu* AssetMenu;
	static USmartMenu* ActorSmartMenu;
	static USmartMenu* ActorMenu;
	static USmartMenu* SequencerToolbarMenu;
	static USmartMenu* MainMenu;

public:
	TArray<TSharedPtr<FJsonValue>> GetMenuItemsDataFromEnv(const FString& Env);
	TArray<USmartMenuItemBase*> GetMenuItemsFromEnv(const FString& Env);
	//void StringSplit(FString * srcStr, const FString &tagStr, TArray<FString> *result);
	void GetMenuItemsFromData(TArray<USmartMenuItemBase*>& Items, TArray<TSharedPtr<FJsonValue>> MenuJsonDatas);
	void InitMenuEnv();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenuHandle* Get() {
		if (SmartMenuHandleInstance == nullptr) {
			SmartMenuHandleInstance = NewObject<USmartMenuHandle>();
			SmartMenuHandleInstance->InitMenuEnv();
		}
		return SmartMenuHandleInstance;
	}
	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetMainMenu();
	
	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetLevelToolbarMenu();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetAssetMenu();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetAssetSmartMenu();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetActorMenu();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetActorSmartMenu();

	UFUNCTION(BlueprintCallable, Category = Python)
	static USmartMenu* GetSequencerToolbarMenu();

};
